<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>论文查重-支付订单</title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <link rel="shortcut icon" href="../pc/assets/favicon.ico" type="image/vnd.microsoft.icon"/>
    <link rel="stylesheet" href="../pc/assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="../pc/assets/css/common.css">
    <link rel="stylesheet" href="../pc/assets/css/pay.css?v=1.1">
    <script>
        var USER_TOKEN = 'RmlETkdPdjYzZmVjNTVhMDAyYzY='
        var JANE_NAME = 'paper_platform';
    </script>
</head>
<body>
<div class="pay_page clearfix" id="App">
    <div class="head col-md-12">
        <div class="logo f-l">
            <img src="../pc/assets/img/logo.png" alt="">
            <a href="./index.html"></a>
        </div>
        <div class="nav f-r">
            <div class="upload-h">
                <a href="./index.html">提交论文</a>
            </div>
            <div class="report-h">
                <a href="./query.html">下载报告</a>
            </div>
        </div>
    </div>
    <div class="content-block">
        <div class="block-left f-l ">
            <div class="operation-process">
                <p class="name">操作流程</p>
                <div class="operation operation1">
                    <div class="sequence sequence-line">01</div>
                    <p class="p1">提交论文</p>
                    <p class="p2">直接上传文档或只粘贴文本</p>
                </div>
                <div class="operation operation2">
                    <div class="sequence sequence-line">02</div>
                    <p class="p1">核对结算</p>
                    <p class="p2">确认订单后可扫码付款</p>
                </div>
                <div class="operation operation3 noMarginBottom">
                    <div class="sequence">03</div>
                    <p class="p1">等待查重结果</p>
                    <p class="p2">检测完成后可下载报告</p>
                </div>
            </div>
            <div class="common-problem">
                <p class="name">常见问题</p>
                <div class="p-cont">
                    <div class="problem-item">
                        <p class="problem-text">
                            <!--                       <img src="" alt="">-->
                            <span>Q</span>
                            大约什么时候能出结果？
                        </p>
                        <p class="answer">通常情况下，整个检测过程需要5至10分钟。如果是在论文检测的高峰期，则可能需要更长的时间</p>
                    </div>
                    <div class="problem-item">
                        <p class="problem-text">
                            <!--                       <img src="" alt="">-->
                            <span>Q</span>
                            论文查重结果准确吗？
                        </p>
                        <p class="answer">正版授权，含百亿的数据库资源，采用最先进的指纹比对扫描技术 ，充分保证用户查重的准确性。用报告编号支持官网验真。</p>
                    </div>
                    <div class="problem-item">
                        <p class="problem-text">
                            <img src="../pc/assets/img/jcxz.png" alt="">
                            检测须知
                        </p>
                        <p class="answer">亲，准备论文查重的文档，一定要<span>word的doc或docx格式；</span>提交查重检测前<span>删除封面、图标、致谢、一级页眉页脚的学校信息；</span>目录、附录、参考文献等要跟提交学校的保持一致；</p>
                    </div>
                </div>
            </div>
        </div>
        <div class="block-right f-l ">
            <div class="r-content">
                <p class="back">
                    <a href="./index.html"><&nbsp;返回提交页</a>
                </p>
                <p class="r-title">确认订单</p>
                <div class="block-information">
                    <p class="name">订单详情</p>
                    <div class="information-box">
                        <div class="info">
                            <p class="time ">下单时间 <span class="time-t"></span></p>
                            <p class="orderId">订单编号 <span class="orderId-t"></span>
                                <span class="copyID">复制</span> <input type="text" id="copyIDInput">
                            </p>
                        </div>
                        <div class="info">
                            <p class="title">标题 <span class="title-t f-r"></span></p>
                            <p class="billing">计费方式 <span class="billing-t f-r"></span></p>
                        </div>
                        <div class="info">
                            <p class="system">系统 <span class="system-t f-r"></span></p>
                            <p class="price">应付金额 <span class="price-t f-r">￥<span class="price-amount"></span></span></p>
                        </div>
                        <div class="info">
                            <p class="wordNum noMarginBottom">字符数 <span class="wordNum-t f-r"></span></p>
                        </div>
                    </div>
                </div>
                <div class="block-coupon">
                    <p class="name">优惠券</p>
                    <div>
                        <input autocomplete="off" class="form-control" onKeyUp="value=value.replace(/[\W]/g,'')" maxlength="30" name="coupon" type="text" placeholder="请输入优惠券兑换码" id="coupon"/>
                        <div class="eliminateCoupon"></div>
                        <span class="use_now">立即使用</span>
                        <span class="errorTip"><img src="../pc/assets/img/err_tip.png" alt=""><span></span></span>
                    </div>
                </div>
                <div class="block-pay">
                    <p class="name">支付</p>
                    <div class="pay-box">
                        <div class="clearfix2">
                            <div class="payType clearfix">
                                <div id="alipay" data-type="alipayScan" class="f-l" style="display: none">
                                    <img src="../pc/assets/img/Alipay.png" alt="">
                                    <span>支付宝支付</span>
                                </div>
                                <div id="wx" data-type="wxScan" class="f-l" style="display: none">
                                    <img src="../pc/assets/img/wx.png" alt="">
                                    <span>微信支付</span>
                                </div>
                                <div id="scanCodeRich" data-type="scanCodeRich" class="f-l" style="display: none">
                                    <img src="../pc/assets/img/scanpay.png" alt="">
                                    <span>扫码支付</span>
                                </div>
                                <div id="thirdparty" data-type="thirdparty" class="f-l" style="display: none">
                                    <img src="../pc/assets/img/dsf.png" alt="">
                                    <span>第三方支付</span>
                                </div>
                            </div>
                            <div class="code clearfix">
                                <div class="pull-left codeER">
                                    <div id="qrcode"></div>
                                    <div class="load">
                                        <img src="../pc/assets/img/loding.gif" alt="">
                                    </div>
                                    <div class="mask">
                                        <img src="../pc/assets/img/expired.png" alt="">
                                        <p>点击刷新</p>
                                    </div>
                                    <p class="tips">提示：扫码支付,请勿刷新页面</p>
                                </div>
                                <div class="pull-left titlesRight payTypeClass">
                                    <div class="amount">应付金额 <span><b>￥</b><span class="orderAmount">00.00</span></span></div>

                                    <div class="payTypes">提示: <span class="UnitPrice">暂无</span> </div>

                                    <p class="auxiliary">剩余支付时间 <span class="time"><span class="payTime">120</span>秒</span>，<span class="next">已支付下一步</span></p>

                                    <div class="tipsBox">
                                        <div class="typeTips">
                                            <img src="../pc/assets/img/wx.png" alt="">
                                            <img src="../pc/assets/img/Alipay.png" alt="">
                                            <!--                                    <img src="../pc/assets/img/ysf.png" alt="">-->
                                            <span>使用微信、支付宝扫码支付 </span>
                                            <!--                                    <span>使用微信扫码支付 </span>-->
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="tbPay">
                                <div class="Options">
                                    <div id="XHS" class="zdyType" data-type="redBook">
                                        <img src="../pc/assets/img/xhs.png" alt="">
                                        小红书订单
                                    </div>
                                    <div id="TB" class="zdyType" data-type="taobao">
                                        <img src="../pc/assets/img/tb.png" alt="">
                                        淘宝订单
                                    </div>
                                </div>

                                <div class="main">
                                    <div class="tb-content">
                                        <div class="tb-idBox">
                                            <label>订单编号：</label>
                                            <input
                                                    autocomplete="off" maxlength="30" name="NumberWords"
                                                    type="text"
                                                    placeholder="填写淘宝订单编号(必填)"
                                                    id="tbTid"
                                                    class="form-control tb-oid noMarginTop" />

                                            <span class="tipsDiv2">
                                        <img src="../pc/assets/img/tipsText.png" alt="">
                                        <div>
                                            不满一件, 按一件计算
                                        </div>
                                    </span>
                                        </div>
                                        <div class="tb-idBox">
                                            <label>备用订单：</label>
                                            <!-- onafterpaste="this.value=this.value.replace(/[^\d]/g,'') "
                                            onkeyup="this.value=this.value.replace(/[^\d]/g,'') "
                                             -->
                                            <input
                                                    autocomplete="off" maxlength="60" name="NumberWords"
                                                    type="text"
                                                    placeholder="数额不足时填写，会合并数额"
                                                    id="tbTid-2"
                                                    class="form-control tb-oid" />
                                            <span class="tipsDiv">
                                            <img src="../pc/assets/img/tipsText2.png" alt="">
                                            <div>
                                                多个备用订单
                                                <br>
                                                请用英文逗号分隔
                                            </div>
                                        </span>
                                        </div>
                                        <div class="errTip"></div>
                                        <div class="tb-payOrder">立即使用</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="mask_body"></div>
    <div class="coupon_pop">
        <input  id="copyInput" type="text">
        <div class="pop_top">
            <div class="pop_title">支付提醒</div>
            <img class="close_pop" src="../pc/assets/img/delete2.png" alt="">
        </div>
        <div class="pop_cont">
            <p class="p1">是否使用免费券支付?</p>
            <div class="back_block">
                <p class="p2">订单编号: <span class="orderId_pop"></span> <span class="copy_pop">复制</span> </p>
                <p class="p3">订单编号是查询和下载报告的唯一标识，请妥善保存。</p>
            </div>
        </div>
        <div class="pop_bottom">
            <div class="cancel_btn">取消</div>
            <div class="determine_btn">确定</div>
        </div>
    </div>
</div>
<script src="../pc/assets/js/jquery.min.js"></script>
<script src="../pc/assets/js/typed.min.js"></script>
<script src="../pc/assets/js/qrcode.min.js"></script>
<script src="../pc/assets/js/coco-message.js"></script>
<script src="../pc/assets/js/common.js?v=1.2"></script>
<script>
    var qrcode = new QRCode(document.getElementById("qrcode"), {
        width: 135,
        height: 135,
    });

    var source = ''

    // 先判断是不是微信端打开的
    let client = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
    if(client){
        source = 7
        if (/(micromessenger)/i.test(navigator.userAgent)) {
            source = 2
        }
    }else{
        source = 1
    }

    function setPriceTips(rawData){
        for(var i=0; i<rawData.length; i++){
            if( rawData[i].goods_id == getQueryVariable('goodsid') ){

                var unitCount = rawData[i].unit_count
                if(rawData[i].unit_count>=10000 && (rawData[i].unit_count%10000==0)){
                    unitCount = rawData[i].unit_count/10000 + '万'
                }
                if(rawData[i].unit_count<10000 && (rawData[i].unit_count%1000==0)){
                    unitCount = rawData[i].unit_count/1000 + '千'
                }
                $(".billing-t").text(rawData[i].selling_price + '元/' + unitCount + '字')
                $(".UnitPrice").text(rawData[i].selling_price + '元/' + unitCount + '字' + '（不满' + unitCount +'字按' + unitCount + '字计算）')
            }
        }
    }

    // 订单信息
    $(".time-t").text(getQueryVariable('created'))
    $(".wordNum-t").text(getQueryVariable('NumberWords'))
    $(".title-t").text(getQueryVariable('title'))
    $(".orderId-t").text(getQueryVariable('order_sn'))
    $(".system-t").text(getQueryVariable('checkSystem'))
    $(".price-amount").text(getQueryVariable('order_amount'))
    // $(".billing-t").text(getQueryVariable('order_amount'))



    //
    var pay_type = ''  //支付方式
    var typeAll = {
        wx: "wxScan",
        alipay: "alipayScan",
        scanCodeRich: "scanCodeRich",
        taobao: "taobao",
        redBook: 'redBook'
    }
    var noPayWay = false // 未配置支付
    var time = 600;
    var pay_id = '';
    var order_sn = '';
    var contentTypeIs = true;
    var timeout = null;
    var timeout2 = null;
    var Timeout = null;
    var isVerify = false;
    var pay_way_public = '';
    var closeMsg = cocoMessage.loading('正在获取价格...');

    if(getQueryVariable('order_sn')){
        order_sn = getQueryVariable('order_sn')
    }else{
        cocoMessage.error('订单丢失,请重新下单',2000);
        location.href = './index.html'
    }

    function tacitPay(goods_info, pay_way) {
        pay_way_public = pay_way
        pay_type = typeAll[pay_way.default]

        if(!pay_way.alipay && !pay_way.wx && !pay_way.scanCodeRich && !pay_way.taobao && !pay_way.redBook){
            noPayWay = true
        }

        if(pay_type == 'scanCodeRich') { // 扫码付
            $('.tipsBox').show()
            $(".code").show();
            $('.titlesRight').removeClass('payTypeClass')
            if(pay_way.taobao || pay_way.redBook) {// 扫码付有自定义订单的时候, 出现左侧选项
                $('#thirdparty').show()
                $('#scanCodeRich').show()
                $('#scanCodeRich').addClass('select')
            }
        }else{
            if(pay_way.alipay) $('#alipay').show()
            if(pay_way.wx) $('#wx').show()
            $('.clearfix2>.payType>div').removeClass('select')
            $('#' + pay_way.default).addClass('select')
            if(pay_way.taobao || pay_way.redBook) { // 第三方订单展示控制
                if(pay_type != 'taobao' && pay_type!='redBook') $('#thirdparty').show()

                if(pay_way.taobao) {
                    $('#TB').show()
                }
                if(pay_way.redBook) {
                    $('#XHS').show()
                }
            }
            // 默认支付方式为淘宝或小红书的时候, 说明没有其他支付方式了
            if(pay_type == 'taobao' || pay_type=='redBook') { // 淘宝或小红书订单(第三方订单)
                $(".code").hide();
                $(".tbPay").show();
                $(".tbPay").css('paddingLeft', 0)

                if(pay_type == 'taobao') { // 默认选中第三方支付方式
                    $('#TB').addClass('Select')
                }else {
                    $('#XHS').addClass('Select')
                }
                placeholder()
            }else {
                $(".code").show();
            }
        }

        if(noPayWay){
            // $(".noPayWay").show()
            // $("#orderAmount2").text(order_amount)
            // $(".pay_Box_y").hide();
            // $("#coupon").attr("placeholder", "请输入优惠券兑换码支付");
            // $(".no_pay_text").show();
            // $("#dateTime").text(getQueryVariable('created'))
            // $("#orderAmount2").text(getQueryVariable('order_amount'))
            // $("#orderIdText").text(getQueryVariable('order_sn'))
            // $(".orderId_pop").text(getQueryVariable('order_sn'))
            closeMsg()
        }else{
            if(pay_type == 'thirdparty'){
                closeMsg()
                return
            }
            payOrder(pay_type)
        }
    }

    function payOrder(payType,price) {
        $('.load').show()
        $(".mask").hide();
        if(pay_type == 'taobao' || pay_type == 'redBook') {
            $('.load').hide()
            closeMsg()
            // pay_id = order_sn
            contentTypeIs = true
            return;
        }
        if(pay_type == 'scanCodeRich'){
            $(".code").show()
            $(".orderAmount").text(price?price:getQueryVariable('order_amount'))
            qrcode.makeCode(getQueryVariable('pay_wap_url') + '/pay/waporder/' + (order_sn?order_sn:getQueryVariable('order_sn')) + '?source=' + source);
            $('.load').hide()
            time = 600
            $('.payTime').text(time)
            $('.order-oid').text(order_sn?order_sn:getQueryVariable('order_sn'))
            if(!order_sn){
                order_sn = getQueryVariable('order_sn')
            }
            contentTypeIs = true
            closeMsg()
            payStatus()
            countdown()
        }else{
            var formData = getFormData({
                order_sn: order_sn || getQueryVariable('order_sn'),
                pay_type,
                source
            })
            $.ajax({
                type: 'post',
                url: urls + '/api/client/pay/payOrder',
                processData: false,
                contentType: false,
                xhrFields: {
                    withCredentials: true
                },
                data: formData,
                success: function(data) {
                    if(data.code == 200) {
                        qrcode.makeCode(data.data.qrlink);
                        $('.orderAmount').text(data.data.payment_money || '0.00')
                        $('.load').hide()
                        time = 600
                        $('.payTime').text(time)
                        pay_id = data.data.pay_id
                        payStatus()
                        countdown()
                    }else if(data.code == 3001) {
                        cocoMessage.success('订单已支付', 2000)
                        window.location.href = "./query.html?oid=" + order_sn + '&editionType=' + getQueryVariable('editionType');
                    }else if(data.code == -1 && data.codeMsg == '不支持的该支付方式'){
                        cocoMessage.error(data.codeMsg, 2000);
                    }else {
                        cocoMessage.error(data.codeMsg, 2000);
                        $(".mask").show()
                        $('.load').hide()
                    }
                    contentTypeIs = true
                    closeMsg()
                },
                error: function(err) {
                    cocoMessage.error("请求失败!请检查网络", 2000);
                    contentTypeIs = true
                    closeMsg()
                }
            });
        }
    }

    // 支付方式切换
    $('.clearfix2>.payType>div').click(function () {
        if(pay_type) {
            if(!contentTypeIs) return
            if($(this).attr('data-type') != pay_type) {
                closeMsg = cocoMessage.loading('正在切换支付方式...');
                contentTypeIs = false
                $('.clearfix2>.payType>div').removeClass('select')
                $(this).addClass('select')
                pay_type = $(this).attr('data-type')
                if(pay_type == 'thirdparty'){
                    thirdpartyPayOrder()
                    return;
                }
                $(".tbPay").hide();
                $(".code").show();
                payOrder()
            }
        }
    })

    // 切换自定义订单提示
    function placeholder() {
        if($('.zdyType.Select').attr('id')=='XHS') {
            $('#tbTid').attr('placeholder' , '填写小红书订单编号(必填)')
        }else {
            $('#tbTid').attr('placeholder' , '填写淘宝订单编号(必填)')
        }
    }

    // 切换到第三方支付
    function thirdpartyPayOrder() {
        $(".code").hide();
        contentTypeIs = true;
        $(".tbPay").show();

        if(pay_way_public.taobao) $('#TB').show()
        if(pay_way_public.redBook) $('#XHS').show()

        // 默认选中第三方支付方式
        if(pay_way_public.redBook) {
            $('#XHS').addClass('Select')
        }else {
            $('#TB').addClass('Select')
        }

        placeholder()
        clearTimeout(Timeout)
        time = 0
        closeMsg();
    }

    // 切换第三方支付方式
    $('.zdyType').click(function() {
        $('.zdyType').removeClass('Select')
        $(this).addClass('Select')
        placeholder()
        $(".errTip").text('')
    })

    // 第三方支付,确认按钮
    var TbPaying = false
    $(".tb-payOrder").click(function (){
        $(".errTip").hide();
        $(".tbPay").removeClass('errInput')
        if(TbPaying){
            return;
        }
        if(!$("#tbTid").val()) {
            $(".errTip").text($('#tbTid').attr('placeholder'))
            $(".tbPay").addClass('errInput')
            $(".errTip").show();
            return
        }
        var closeMsgTb = cocoMessage.loading("订单支付中", 2000);
        let formData = getFormData({
            order_sn: order_sn || getQueryVariable('order_sn'),
            pay_type: $('.zdyType.Select').attr('data-type'),
            tids: $("#tbTid").val() + ($('#tbTid-2').val()?(','+$('#tbTid-2').val()):''),
            source
        })
        TbPaying = true
        $.ajax({
            type: 'post',
            url: urls + '/api/client/pay/payOrder',
            processData: false,
            contentType: false,
            xhrFields: {
                withCredentials: true
            },
            data: formData,
            success: function (data) {
                TbPaying = false
                if(data.code == 200){

                }else{
                    if(data.code == 3001){
                        cocoMessage.success('订单已支付', 2000)
                        window.location.href = window.location.origin + "/query_order?oid=" + order_sn + '&editionType=' + getQueryVariable('editionType');
                        return
                    }
                    $(".tbPay").addClass('errInput')
                    $(".errTip").text(data.codeMsg)
                    $(".errTip").show();
                }
            },
            error: function (err) {
                TbPaying = false
                cocoMessage.error("请求失败!请检查网络", 2000);
                contentTypeIs = true
            },
            complete: function (){
                closeMsgTb()
            }
        })
    })

    // 支付倒计时
    function countdown(){
        clearTimeout(timeout2)
        timeout2 = setTimeout(function (){
            time --
            $('.payTime').text(time>0? time : 0)
            if(time > 0){
                countdown()
            }
        },1000)
    }

    // 订单轮询
    function payStatus() { // 轮询
        clearTimeout(Timeout);
        $.ajax({
            type: 'get',
            url: urls + '/apirs/order/is_pay?pay_id=' + order_sn,
            xhrFields: {
                withCredentials: true
            },
            success: function (res) {
                clearTimeout(Timeout);
                if (time <= 0) {
                    $(".mask").show();
                }
                if (!res.data) {
                    if (time > 0) {
                        Timeout = setTimeout(function () {
                            payStatus();
                        }, 1000);
                    }
                }else {
                    clearTimeout(Timeout);
                    window.location.href = "./query.html?oid=" + order_sn + '&editionType=' + getQueryVariable('editionType');
                }
            },
            error: function () {
                cocoMessage.error("请求失败!请检查网络", 2000);
            },
        });
    }

    // 刷新支付二维码
    $('.code .mask').click(function() { // 点击刷新
        $(".mask").hide();
        $('.load').show();
        payOrder()
    })

    // 下一步
    $('.next').click(function() {
        if(isVerify) return
        isVerify = true
        setTimeout(() => {
            isVerify = false
        },3000)
        var form_data = getFormData({
            pay_id: order_sn
        })
        $.ajax({
            type: 'post',
            url: urls + '/api/client/pay/verifyOrder',
            processData: false,
            contentType: false,
            xhrFields: {
                withCredentials: true
            },
            data: form_data,
            success: function (res) {
                if (res.code == 3001) {
                    cocoMessage.destroyAll();
                    cocoMessage.success('订单已支付', 2000)
                    window.location.href = "./query.html?oid=" + order_sn;
                }else {
                    cocoMessage.destroyAll();
                    cocoMessage.error("您的订单未支付", 2000);
                }
            },
            error: function () {
                cocoMessage.error("请求失败!请检查网络", 2000);
            },
            complete: function () {
                isVerify = false
            }
        });
    })

    $("#coupon").on('input',function (){
        if($(this).val().length > 0){
            $(".use_now").addClass('can')
            $(".eliminateCoupon").css('display','inline-block')
        }else{
            $(".use_now").removeClass('can')
            $(".eliminateCoupon").hide()
        }
    })

    $(".eliminateCoupon").on('click', function (){
        $("#coupon").val('')
        $("#coupon").trigger('input')
    })

    $("#coupon").on('change',function (){
        $(".errorTip").hide();
    })

    let canClick = true;
    $(".use_now").on('click',function() {
        if(!canClick){
            return
        }
        canClick = false
        closeMsg = cocoMessage.loading('正在兑换优惠券...');

        var formData = getFormData({
            order_sn: order_sn || getQueryVariable('order_sn'),
            code: $("#coupon").val()
        })

        $.ajax({
            type: 'post',
            url: urls + '/api/client/order/variation/order',
            data: formData,
            contentType: false,
            processData: false,
            xhrFields: {
                withCredentials: true
            },
            success: function (res) {
                canClick = true
                closeMsg()
                if (res.code == 200) {
                    $('.orderId_pop').text(res.data.order_sn)
                    $('.order-oid').text(res.data.order_sn)
                    if(Number(res.data.order_amount) == 0) {
                        $(".coupon_pop").show();
                        $(".mask_body").show();
                    }else{
                        if(noPayWay){
                            cocoMessage.error("此优惠券不满足免单条件！", 2000);
                            return;
                        }
                        $(".oid").text(res.data.order_sn)
                        order_sn = res.data.order_sn
                        payOrder('',res.data.order_amount)
                    }
                }else {
                    // cocoMessage.error(res.codeMsg, 2000);
                    $(".errorTip span").text(res.codeMsg)
                    $(".errorTip").css('display','inline-block');
                    closeMsg()
                }
            },
            error: function () {
                cocoMessage.error("请求失败!请检查网络", 2000);
                contentTypeIs = true
                closeMsg()
                canClick = true
            },
        });

    })

    $(".copy_pop").on('click',function (){
        var text = $(".orderId_pop").text()
        $("#copyInput").val(text)
        $("#copyInput").select()
        try {
            var state = document.execCommand("copy");
        } catch (err) {
            var state = false;
        }
        if (state) {
            cocoMessage.success(1000, "复制成功", function() {
            });
        } else {
            cocoMessage.error(1000, "复制失败", function() {
            });
        }
    })

    $(".copyID").on('click',function (){
        var text = $(".orderId-t").text()
        $("#copyIDInput").val(text)
        $("#copyIDInput").select()
        try {
            var state = document.execCommand("copy");
        } catch (err) {
            var state = false;
        }
        if (state) {
            cocoMessage.success(1000, "复制成功", function() {
            });
        } else {
            cocoMessage.error(1000, "复制失败", function() {
            });
        }
    })

    $(".copy_oid").on('click',function (){
        var text = $(".oid").text()
        $("#copyInput2").val(text)
        $("#copyInput2").select()
        try {
            var state = document.execCommand("copy");
        } catch (err) {
            var state = false;
        }
        if (state) {
            cocoMessage.success(1000, "复制成功", function() {
            });
        } else {
            cocoMessage.error(1000, "复制失败", function() {
            });
        }
    })

    function couponsPay() {
        var formData2 = getFormData({
            order_sn: $('.orderId_pop').text(),
            pay_type: 'coupons',
            source
        })
        $.ajax({
            type: 'post',
            url: urls + '/api/client/pay/payOrder',
            data: formData2,
            contentType: false,
            processData: false,
            xhrFields: {
                withCredentials: true
            },
            success: function (res) {
                if (res.code == 200) {

                }else if(res.code == 3001) {
                    cocoMessage.success('订单已支付', 2000)
                    window.location.href = "./query.html?oid=" + $('.orderId_pop').text() + '&editionType=' + getQueryVariable('editionType');
                }else {
                    cocoMessage.error(res.codeMsg, 2000);
                    closeMsg()
                }
            },
            error: function () {
                cocoMessage.error("请求失败!请检查网络", 2000);
                contentTypeIs = true
                closeMsg()
            },
        });
    }

    $(".close_pop").on('click',function (){
        $(".coupon_pop").hide();
        $(".mask_body").hide();
    })
    $(".cancel_btn").on('click',function (){
        $(".coupon_pop").hide();
        $(".mask_body").hide();
    })
    $(".determine_btn").on('click',function (){
        couponsPay()
    })
</script>
</body>
</html>